
package com.wyzz.hr.base;

import java.util.Iterator;
import java.util.List;

import com.wyzz.hr.bo.IHasAuthBO;
import com.wyzz.hr.spring.SpringBeanFactory;


public class DWRUtil implements Constants {

	public DWRUtil() {
	}

	public static String checkAuth(String actionName, String methodName) {
		Iterator iterator;
		List userAuthorityList = ActionAuths.getActionAuths(actionName,
				methodName);
		if (userAuthorityList == null || userAuthorityList.size() < 1)
			return null;
		iterator = userAuthorityList.iterator();
		while (iterator.hasNext()) {
			UsersAuthority userAuthority = (UsersAuthority) iterator.next();
			try {
				if (!bo.hasDWRAuth(userAuthority))
					break;
			} catch (Exception e) {
				e.printStackTrace();
				return "error";
			}
			String filter = userAuthority.getFilter();
			return filter;
		}
		return "error";
	}

	public static final String DWR_ERROR = "error";
	private static IHasAuthBO bo = (IHasAuthBO) SpringBeanFactory
			.getBean("hasService");

}
